export default {
  getItem(key) {
    let value = null
    try {
      value = localStorage.getItem(key)
    } catch (ex) {
      // 开发环境下提示error
      // if (__DEV__) {
        console.error('localStorage.getItem报错, ', ex)
      // }
    } finally {
      return value
    }
  },
  setItem(key, value) {
    try {
      // ios safari 无痕模式下，直接使用 localStorage.setItem 会报错
      localStorage.setItem(key, value)
    } catch (ex) {
      // 开发环境下提示 error
      // if (__DEV__) {
        console.error('localStorage.setItem报错, ', ex)
      // }
    }
  },
  clear(key) {
    try {
      key ?
      localStorage.removeItem(key) :
      localStorage.clear()
    } catch (ex) {
      console.error('localStorage.clear报错:', ex);
    }
  }
}